package cn.psvmc.cxzapi.service.ticket;

import cn.psvmc.cxzapi.config.mybatisplus.service.impl.AbstractService;
import cn.psvmc.cxzapi.mapper.ticket.TTicketMapper;
import cn.psvmc.cxzapi.mapper.ticket.TTicketRepliesMapper;
import cn.psvmc.cxzapi.model.ticket.TTicketReplies;
import cn.psvmc.cxzapi.service.system.ServiceUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 工单处理表 服务实现类
 * @Author auto
 * @Date 2024-08-12
 */
@Service
public class TTicketRepliesService extends AbstractService<TTicketRepliesMapper, TTicketReplies> {

    @Resource
    private TTicketRepliesMapper tTicketRepliesMapper;
    @Resource
    private TTicketMapper tTicketMapper;
    @Resource
    private ServiceUtil serviceUtil;

    /**
    * @Date auto 2024-08-12 新增工单处理表
    * @Param tTicketReplies 工单处理表
    * @Return int
    */
    public int add(TTicketReplies tTicketReplies){
        serviceUtil.checkTicket(tTicketMapper.selectById(tTicketReplies.getTicketId()));//校验工单是否存在且未关闭
        tTicketReplies.setUsertype(1);
        return tTicketRepliesMapper.insert(tTicketReplies);
    }

    /**
     * @Description 处理详情
     * @Date 2024/8/13 14:40
     * @Author YWX
     * @Param [ticketId]
     * @Return java.util.Map
     **/
    public Map detail(Integer ticketId){
        return tTicketRepliesMapper.findByTicketId(ticketId);
    }
}
